import { http } from "@/utils/http";

// 获取人员
export const getPersonListAPI = (data = { pageSize: 99999, page: 1 }) => {
  return http.request("post", "/account/user/listPage", {
    data
  });
};

// 获取角色
export const getRoleListAPI = () => {
  return http.request(
    "get",
    "/account/role/listPage?pageSize=99999&page=1&sortBy=desc&sortName=id&sysCode=sys-ifp&roleKeyLike=&roleNameLike=&rolenameLike=&rolekeyLike=&status=-1"
  );
};

// 获取岗位
export const getWorkListAPI = () => {
  return http.request("get", "/account/position/listPage?positionNameLike=&positionKeyLike=&positionTypeLike=&pageSize=99999&page=1&total=0");
};

// 获取组织树
export const getOrganizationListAPI = () => {
  return http.request("post", "/account/api/v1/dept/listDeptOptionTree", {});
};

// 上传文件
export const uploadFileAPI = data =>
  http.request(
    "post",
    `/dms/api/v1/doc/upload`,
    { data },
    {
      headers: {
        noLoading: true,
        "content-type": "application/x-www-form-urlencoded"
      }
    }
  );

// 加载文件夹树
export const loadTreeAPI = data => {
  return http.request("post", "/dms/api/v1/doc/loadTree", {
    data
  });
};

// 新增文件夹
export const addFolderAPI = data => {
  return http.request("post", "/dms/api/v1/doc/addTree", {
    data
  });
};

// 修改文件夹
export const editFolderAPI = data => {
  return http.request("post", "/dms/api/v1/doc/editTree", {
    data
  });
};

// 删除文件夹
export const deleteFolderAPI = data => {
  return http.request("post", "/dms/api/v1/doc/delTree", {
    data
  });
};

// 查询文档
export const searchDocAPI = data => {
  return http.request("post", "/dms/api/v1/doc/searchDoc", {
    data
  });
};

// 移动
export const moveFolderAPI = data => {
  return http.request("post", "/dms/api/v1/doc/moveTo", {
    data
  });
};

// 收藏
export const storeAPI = data => {
  return http.request("post", "/dms/api/v1/doc/favorite", {
    data
  });
};

// 取消收藏
export const cancelStoreAPI = data => {
  return http.request("post", "/dms/api/v1/doc/unfavorite", {
    data
  });
};

// 下载
export const downloadAPI = data => {
  return http.request("post", "/dms/api/v1/doc/download", {
    data
  });
};

// 删除
export const deleteAPI = data => {
  return http.request("post", "/dms/api/v1/doc/del", {
    data
  });
};

// 归档
export const archiveAPI = data => {
  return http.request("post", "/dms/api/v1/doc/archive", {
    data
  });
};

// 取消归档
export const cancelArchiveAPI = data => {
  return http.request("post", "/dms/api/v1/doc/unarchive", {
    data
  });
};

// 文件详情
export const fileDetailAPI = data => {
  return http.request("post", "/dms/api/v1/doc/detail", {
    data
  });
};

// 重命名
export const reNameAPI = data => {
  return http.request("post", "/dms/api/v1/doc/rename", {
    data
  });
};

// 预览
export const previewAPI = data => {
  return http.request(
    "post",
    "/dms/api/v1/doc/preview",
    {
      data
    },
    {
      responseType: "blob"
    }
  );
};

// 预览PPTX
export const previewPPTXAPI = data => {
  return http.request(
    "post",
    "/dms/api/v1/training/previewPPTx",
    {
      data
    },
    {
      responseType: "blob"
    }
  );
};

// 高级搜索
export const advancedSearchAPI = data => {
  return http.request("post", "/dms/api/v1/doc/advanceSearch", {
    data
  });
};

// 查看权限
export const getAuthorityAPI = data => {
  return http.request("post", "/dms/api/v1/doc/viewAuth", {
    data
  });
};

// 开启权限
export const openAuthorityAPI = data => {
  return http.request("post", "/dms/api/v1/doc/showAuth", {
    data
  });
};

// 关闭权限
export const closeAuthorityAPI = data => {
  return http.request("post", "/dms/api/v1/doc/hideAuth", {
    data
  });
};

// 保存权限
export const saveAuthorityAPI = data => {
  return http.request("post", "/dms/api/v1/doc/saveAuth", {
    data
  });
};

// 移除权限
export const deleteAuthorityAPI = data => {
  return http.request("post", "/dms/api/v1/doc/delAuth", {
    data
  });
};
